🛡️ Sentinel: [CRITICAL] Fix SQL injection in database kwargs unpacking#58
Draft
davidjuarezdev wants to merge 1 commit intomainfrom
Draft
🛡️ Sentinel: [CRITICAL] Fix SQL injection in database kwargs unpacking#58davidjuarezdev wants to merge 1 commit intomainfrom
davidjuarezdev wants to merge 1 commit intomainfrom
Conversation
Co-authored-by: davidjuarezdev <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚨 Severity: CRITICAL
💡 Vulnerability: The
containsandremovemethods instreamrip/db.pyused**items(kwargs) and directly used those dictionary keys in dynamic SQL condition string formatting. Thecontainsmethod attempted validation but relied onassert, which is bypassed entirely when Python runs with optimization (-O). Theremovemethod lacked validation completely. This opened the door for SQL injection where an attacker could pass arbitrary conditions via arbitrary keys in the unpacked kwargs.🎯 Impact: If these methods were called with externally controlled or unsanitized keys passed as
**kwargs, it would result in arbitrary SQL execution, leading to data deletion or extraction.🔧 Fix: Removed the
assertstatement incontainsand added explicit validation logic usingif not ...: raise ValueError(...). Additionally, added this same rigorous validation to theremovemethod to prevent SQL injection when interpolating the dictionary keys into theDELETEcommand string.✅ Verification: Run
PYTHONPATH=. poetry run pytest testsand ensure the database queries properly enforce the structure keys.PR created automatically by Jules for task 18369353087076288712 started by @davidjuarezdev